package com.funtl.framework.web.action.log;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import net.sf.json.JSONObject;

import org.springframework.context.annotation.Scope;

import com.funtl.framework.java.abstracts.AbstractAction;
import com.funtl.framework.web.entity.LogError;
import com.funtl.framework.web.service.log.ILogErrorService;

/**
 * 错误日志
 * @author WMLI
 * Create on 2013-5-16
 */
@Scope("prototype")
public class LogErrorAction extends AbstractAction {
	private static final long serialVersionUID = 214298402283682544L;
	private JSONObject result;
	private Map<String, Object> request;
	private Map<String, Object> session;
	
	private ILogErrorService logErrorService;
	
	//参数
	private int page;
	private int rows;
	
	//page
	
	public String error_manager() throws Exception {
		return SUCCESS;
	}
	
	//common action
	
	@Override
	public String get() throws Exception {
		return null;
	}

	@Override
	public String query() throws Exception {
		LogError logError = new LogError();
		logError.setPageIndex(page);
		logError.setPageSize(rows);
		
		List<LogError> list = logErrorService.page(logError);
		jsonData.put("total", logErrorService.getCount(logError));
		jsonData.put("rows", list);
		result = JSONObject.fromObject(jsonData);
		return SUCCESS;
	}

	@Override
	public String insert() throws Exception {
		return null;
	}

	@Override
	public String delete() throws Exception {
		logErrorService.delete(new LogError());
		result = JSONObject.fromObject(jsonData);
		return SUCCESS;
	}

	@Override
	public String update() throws Exception {
		return null;
	}
	
	//getter setter

	public JSONObject getResult() {
		return result;
	}

	public void setResult(JSONObject result) {
		this.result = result;
	}

	public Map<String, Object> getRequest() {
		return request;
	}

	public void setRequest(Map<String, Object> request) {
		this.request = request;
	}

	public Map<String, Object> getSession() {
		return session;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public ILogErrorService getLogErrorService() {
		return logErrorService;
	}

	@Resource
	public void setLogErrorService(ILogErrorService logErrorService) {
		this.logErrorService = logErrorService;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}
	
}
